var CryptoJS = require('../utils/tripledes.js');
var pwd = 'lj588288';  //这里需要传入8个字节以上的密钥
var iv = '64896563'; //偏移量

//加密
function encrypt(val) {
  var encryptData = encryptByDESModeCBCUtf8to64(val, pwd, iv);
  return encryptData;
}
function encryptByDESModeCBCUtf8to64(message, key, iv) {
  var keyHex = CryptoJS.enc.Utf8.parse(key);
  var ivHex = CryptoJS.enc.Utf8.parse(iv);
  var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
    iv: ivHex,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
  })
  return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
}
module.exports = {
  encrypt: encrypt
}